Developer Documentation

QuickTime 4 API Documentation

QuickTime 4 Reference

| Previous | Chapter Contents | Chapter Top | Next |

Specifying Other Capabilities of Your Component

The base image decompressor gets additional information about the capabilities of your image decompressor component by calling your component's ImageCodecPreflight function. The base image decompressor uses this information when responding to a call to the ImageCodecPredecompress function, which the Image Compression Manager makes before decompressing an image.

Your image decompressor component returns information about its capabilities by filling in the capabilities structure. Listing 3 illustrates how to fill in this structure. In this example, the decompressor component specifies that it supports the ARGB, ABGR, BGRA, and RGBA pixel formats used by Microsoft Windows.

Listing 3 Sample implementation of ImageCodecPreflight

pascal ComponentResult ImageCodecPreflight (
                         ComponentInstance ci,
                         CodecDecompressParams *p)
{
    register CodecCapabilities*capabilities = p->capabilities;

    /*  Decide which depth compressed data we can deal with. */
    
    switch ( (*p->imageDescription)->depth ) {
        case 16:
            break;
        default:
            return(codecConditionErr);
            break;
    }
    
    /*  We can deal only 32 bit pixels. */
    capabilities->wantedPixelSize = 32;
    
    /*  The smallest possible band we can do is 2 scan lines. */
    
    capabilities->bandMin = 2;

    /*  We can deal with 2 scan line high bands. */

    capabilities->bandInc = 2;
    
    /*  If we needed our pixels to be aligned on some integer
     *  multiple we would set these to
     *  the number of pixels we need the dest extended by.
     *  If we dont care, or we take care of
     *  it ourselves we set them to zero.
     */

    capabilities->extendWidth = p->srcRect.right & 1;
    capabilities->extendHeight = p->srcRect.bottom & 1;

    {
        OSType *pf = *glob->wantedDestinationPixelTypeH;

        p->wantedDestinationPixelTypes =
            glob->wantedDestinationPixelTypeH;

        // set up default order
        pf[0] = k32BGRAPixelFormat;
        pf[1] = k32ARGBPixelFormat;
        pf[2] = k32ABGRPixelFormat;
        pf[3] = k32RGBAPixelFormat;

        switch (p->dstPixMap.pixelFormat) {
        case k32BGRAPixelFormat: // we know how to do these pixel formats
            break;
        case k32ABGRPixelFormat:
            pf[0] = k32ABGRPixelFormat;
            pf[1] = k32BGRAPixelFormat;
            pf[2] = k32ARGBPixelFormat;
            pf[3] = k32RGBAPixelFormat;
            break;
        case k32ARGBPixelFormat:
            pf[0] = k32ARGBPixelFormat;
            pf[1] = k32BGRAPixelFormat;
            pf[2] = k32ABGRPixelFormat;
            pf[3] = k32RGBAPixelFormat;
            break;
        case k32RGBAPixelFormat:
            pf[0] = k32RGBAPixelFormat;
            pf[1] = k32BGRAPixelFormat;
            pf[2] = k32ARGBPixelFormat;
            pf[3] = k32ABGRPixelFormat;
            break;

        default:            // we don't know how to do these, so return
                            // the default
            break;
        }
    }

    return(noErr);
}

© 1999 Apple Computer, Inc.

| Previous | Chapter Contents | Chapter Top | Next |